package com.ruoyi.web.controller.check;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.check.service.IECheckListFormItemService;
import com.ruoyi.check.service.IECheckListFormNameService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.check.domain.SysCheck;
import com.ruoyi.check.service.ISysCheckService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检点表详情Controller
 *
 * @author hugh.sun
 * @date 2023-03-03
 */
@RestController
@RequestMapping("/check/check")
public class SysCheckController extends BaseController
{
    @Autowired
    private ISysCheckService sysCheckService;
    @Autowired
    private IECheckListFormNameService ieCheckListFormNameService;
    @Autowired
    private IECheckListFormItemService ieCheckListFormItemService;

    /**
     * 查询检点表详情列表
     */
    @Log(title = "timu")
    @PreAuthorize("@ss.hasPermi('check:check:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysCheck sysCheck)
    {
        startPage();

        String name1 = sysCheck.getName();
        String createName = sysCheck.getCreateName();
        //List<SysCheck> list = sysCheckService.selectSysCheckList(sysCheck);
        //搞一个集合。拿到对应的所有的表的题目
        String name = "表名";
        //去数据库中根据表名拿到所有的列


        return null;

        //return getDataTable(list);
    }

    /**
     * 导出检点表详情列表
     */
    @PreAuthorize("@ss.hasPermi('check:check:export')")
    @Log(title = "检点表详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysCheck sysCheck)
    {
        List<SysCheck> list = sysCheckService.selectSysCheckList(sysCheck);
        ExcelUtil<SysCheck> util = new ExcelUtil<SysCheck>(SysCheck.class);
        util.exportExcel(response, list, "检点表详情数据");
    }

    /**
     * 获取检点表详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:check:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysCheckService.selectSysCheckById(id));
    }

    /**
     * 新增检点表详情
     */
    @PreAuthorize("@ss.hasPermi('check:check:add')")
    @Log(title = "检点表详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysCheck sysCheck)
    {
        return toAjax(sysCheckService.insertSysCheck(sysCheck));
    }

    /**
     * 修改检点表详情
     */
    @PreAuthorize("@ss.hasPermi('check:check:edit')")
    @Log(title = "检点表详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysCheck sysCheck)
    {
        return toAjax(sysCheckService.updateSysCheck(sysCheck));
    }

    /**
     * 删除检点表详情
     */
    @PreAuthorize("@ss.hasPermi('check:check:remove')")
    @Log(title = "检点表详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysCheckService.deleteSysCheckByIds(ids));
    }
}
